# -*- coding: utf-8 -*-
"""
BASP相关接口
处理BASP分型图片等相关功能
"""

from fastapi import APIRouter, HTTPException
from src.services.file_service import FileService
from src.utils.logger import app_logger as logger


# 创建路由器
router = APIRouter()

# 文件服务实例
file_service = FileService()


@router.get("/basp-detail")
async def get_basp_detail():
    """
    获取BASP分型图片详情
    
    Returns:
        dict: 包含BASP分型图片签名URL的响应
    """
    try:
        # BASP分型图片的OSS路径
        basp_oss_path = "ewentianshi/static/basp分型.png"
        
        # 生成签名URL，有效期7天
        signed_url = file_service.generate_signed_url(
            oss_path=basp_oss_path,
            expire_seconds=7 * 24 * 3600  # 7天
        )
        
        logger.info(f"生成BASP分型图片签名URL: {signed_url}")
        
        return {
            "success": True,
            "message": "获取BASP分型图片成功",
            "data": {
                "image_url": signed_url
            }
        }
        
    except Exception as e:
        logger.error(f"获取BASP分型图片失败: {str(e)}")
        raise HTTPException(
            status_code=500,
            detail="获取BASP分型图片失败"
        )